package com.hcrazy.manchester.app.jdbc;

import java.util.ArrayList;
import java.util.List;

import com.hcrazy.manchester.app.pojo.Feedback;
import com.hcrazy.manchester.app.pojo.PageModel;

public class FeedbackDAO extends BaseDAO<Feedback>{

	public void addFeedback(Feedback Feedback) throws Exception{
		StringBuilder sb = new StringBuilder();
		sb.append("insert into him_more_feedback(");
		sb.append("phone,email,content,name,userId,createTime");
		sb.append(") values (");
		sb.append(":phone,:email,:content,:name,:userId,:createTime");
		sb.append(")");
		
		update(sb.toString(), Feedback);
	}
	
	public PageModel getPagedFeedbacks(PageModel model) throws Exception{
		StringBuilder querySQL = new StringBuilder(" select * from him_more_feedback m ");
		StringBuilder countSQL = new StringBuilder(" select count(*) from him_more_feedback m ");
		
		StringBuilder whereSQL = new StringBuilder(" where 1=1 ");
		List<Object> paramList = new ArrayList<Object>();
		
		return this.getPageModel(model, querySQL, countSQL, whereSQL, paramList, Feedback.class);
	}
	
	public Feedback getById(long feedbackId) throws Exception{
		String sql = "select * from him_more_feedback where feedbackId = ?";
		return this.getJavaBean(sql, Feedback.class, feedbackId);
	}
	
	public void delFeedback(int feedbackId) throws Exception{
		String sql = "delete from him_more_feedback where feedbackId = ?";
		this.commonUpdate(sql, feedbackId);
	}
	
}
